package flc.ast;

import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.DebugFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.NetworkFragment;
import flc.ast.fragment.TestFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.rlHome));
        listFragment.add(new FragmentViewBinder(DebugFragment.class, R.id.rlDebug));
        listFragment.add(new FragmentViewBinder(NetworkFragment.class, R.id.rlNetwork));
        listFragment.add(new FragmentViewBinder(TestFragment.class, R.id.rlTest));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.rlMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.rlHome:
                mDataBinding.ivHomeSel.setVisibility(View.VISIBLE);
                break;
            case R.id.rlDebug:
                mDataBinding.ivDebugSel.setVisibility(View.VISIBLE);
                break;
            case R.id.rlNetwork:
                mDataBinding.ivNetworkSel.setVisibility(View.VISIBLE);
                break;
            case R.id.rlTest:
                mDataBinding.ivTestSel.setVisibility(View.VISIBLE);
                break;
            case R.id.rlMy:
                mDataBinding.ivMySel.setVisibility(View.VISIBLE);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHomeSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivDebugSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivNetworkSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivTestSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivMySel.setVisibility(View.INVISIBLE);
    }

}